--[[
 -- *名称:AbstractSuitType
 -- *描述:抽象牌型,考虑牌型是个enum，用类标识便于拓展
 -- *版权:Copyright © 2016-2018 深圳市三只小熊科技有限公司 版权所有
 -- *作者:Administrator
 -- *创建日期:2017-11-08
 -- *修改日期:2017-11-08
 ]]
local AbstractSuitType = pokercore.class();

--默认牌型权值-1
AbstractSuitType.DEFAULT_TYPE_WEIGHT = -1 ;

--设置元表
local mt = {};

mt.__tostring = function (t)
   return "AbstractSuitType" .. " [type=" .. (t.type or nil).. ", weight=" .. (t.weight or nil).. "]";
end


-- mt.__eq = function (c1, c2) 
--    if not c2 or not c1 then
--       return false ;
--    elseif c1 == c2 then
--    	  return true ;
--    end 
--    return (c1.type  ==  c2.type) and (c1.weight  ==  c2.weight) ;
-- end

function AbstractSuitType:equals(o1)
   if not o1 then
      return false ;
   elseif self == o1 then
      return true ;
   end
   return (self.type == o1.type) and (self.weight  ==  o1.weight) ;
end



---
 -- [ctor 默认类的构造方法]
 -- @DateTime 2017-09-20
 -- @param     [description]
 -- @return    [description]
 --
function AbstractSuitType:ctor(type,weight)
   self.type = type ;
   self.weight = weight or AbstractSuitType.DEFAULT_TYPE_WEIGHT;
   local meta = getmetatable(self) or {};
   table.merge(meta,mt)
   setmetatable(self,meta)
end


function AbstractSuitType:compareTo(o)
	if not o then
		return 1 ;
	else
      if self.weight - o.weight == 0 then
         return self.type - o.type  ;
      end
		return self.weight - o.weight ;
	end

end

function AbstractSuitType:getType()
	return self.type ;
end

function AbstractSuitType:getWeight()
	return self.weight ;
end


---
 -- [dtor 默认类的销毁方法]
 -- @DateTime 2017-09-20
 -- @param     [description]
 -- @return    [description]
 --
function AbstractSuitType:dtor(...)
  
end

return AbstractSuitType;

